package cn.ztuo.bitrade.dao;

import cn.ztuo.bitrade.dao.base.BaseDao;
import cn.ztuo.bitrade.entity.Award;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.math.BigDecimal;

public interface AwardDao extends BaseDao<Award> {

    Award findByUidAndType(Long uid,Long type);

    @Query(value = "SELECT SUM(ca.number) FROM award ca WHERE ca.status =1 and type <>1 and unit = :unit and to_days(ca.create_time) = to_days(now()) ",nativeQuery = true)
    BigDecimal sumAward(@Param("unit") String unit);

}
